<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:ez="http://java.sun.com/jsf/composite/ezcomp"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:ca="http://java.sun.com/jsf/composite/cashier">


    <ui:define name="content">

        <h:panelGroup rendered="true" >
            <h:form>
                <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
                <p:panel  header="Channelling Bills By Single Cashier">

                    <h:panelGrid columns="2" >
                        <h:outputLabel value="From Date"/>
                        <p:calendar id="frmDate" value="#{channelReportController.fromDate}" navigator="true"  pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>

                        <h:outputLabel value="To Date"/>
                        <p:calendar id="toDate" value="#{channelReportController.toDate}" navigator="true" pattern="dd MMMM yyyy HH:mm:ss" >
                        </p:calendar>
                        <h:outputLabel styleClass="noPrintButton" value="User Name"/>
                        <p:autoComplete converter="webUs" completeMethod="#{webUserController.completeUser}" styleClass="noPrintButton"
                                        forceSelection="true"
                                        var="w" itemLabel="#{w.webUserPerson.name}" itemValue="#{w}"
                                        value="#{channelReportController.webUser}" ></p:autoComplete>

                    </h:panelGrid>
                    <p:panel id="reportPrint" >
                        <h:panelGrid columns="5" >
                            <p:spacer width="50" height="1"/>
                            <p:commandButton id="btnRefresh" ajax="false" value="Process" styleClass="noPrintButton" action="#{channelReportController.createChannelCashierBillList}" style="float: right;"/>
                            <p:defaultCommand target="btnRefresh"/>

                            <p:commandButton ajax="false" value="Print" styleClass="noPrintButton" style="float: right;" >
                                <p:printer target="reportPrint"  />
                            </p:commandButton>

                            <p:commandButton actionListener="#{channelReportController.createChannelCashierBillList}" ajax="false" value="Excel" styleClass="noPrintButton" style="float: right;" >
                                <pe:exporter type="xlsx" target="tbl,tb2,tb3" fileName="Cashier_Detailed_Report"  />
                            </p:commandButton> 
                        </h:panelGrid>

                        <p:panel>
                            <p:dataTable id="tbl"  value="#{channelReportController.billedBillList.bills}" var="b">
                                <f:facet name="header">  
                                    <h:outputLabel value="Channel Bills &emsp; #{channelReportController.webUser.webUserPerson.name}"/>
                                    <h:outputLabel value="From : " style=" white-space:pre-line;"/>
                                    <h:outputLabel  value="#{channelReportController.fromDate}" >
                                        <f:convertDateTime pattern="dd MMM yyyy HH:mm a"/>
                                    </h:outputLabel>                          
                                    <h:outputLabel value="&emsp;&emsp;To :"/>
                                    <h:outputLabel  value="#{channelReportController.toDate}" >
                                        <f:convertDateTime pattern="dd MMM yyyy HH:mm a"/>
                                    </h:outputLabel>
                                </f:facet>     

                                <p:column headerText="Billed No."  >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Billed No."/>
                                    </f:facet> 
                                    <h:outputLabel value="#{b.insId}" >
                                    </h:outputLabel>
                                </p:column>
                                <p:column headerText="Time"   >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Time"/>
                                    </f:facet> 
                                    <h:outputLabel value="#{b.createdAt}" >
                                        <f:convertDateTime pattern="hh:mm a"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Total" styleClass="averageNumericColumn">
                                    <h:outputLabel value="#{b.total}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Discount" styleClass="averageNumericColumn">
                                    <h:outputLabel value="#{b.discount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Cash" styleClass="averageNumericColumn"  >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Cash"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00" />
                                </p:column>
                                <p:column headerText="Credit" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Agent"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Agent'}" value="#{b.netTotal}"  >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Agent'}" value="0.00"/>

                                </p:column>

                                <p:column headerText="C Card" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="C Card"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
                                </p:column>

                                <p:column headerText="Checque" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Checque"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Cheque'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Cheque'}" value="0.00"/>
                                </p:column>

                                <p:column headerText="Slip" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Slip"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Slip'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Slip'}" value="0.00"/>
                                </p:column>

                                <p:columnGroup type="footer">  
                                    <p:row>                                 
                                        <p:column colspan="4"/>
                                        <p:column footerText="#{channelReportController.billedBillList.cash}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.billedBillList.cash}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.billedBillList.agent}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.billedBillList.agent}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.billedBillList.card}" styleClass="averageNumericColumn">  
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.billedBillList.card}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.billedBillList.cheque}" styleClass="averageNumericColumn"> 
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.billedBillList.cheque}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.billedBillList.slip}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.billedBillList.slip}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                    </p:row>  
                                </p:columnGroup>  

                            </p:dataTable>

                            <p:spacer height="30"/>

                            <p:dataTable id="tb2"  value="#{channelReportController.canceledBillList.bills}" var="b">
                                <f:facet name="header">  
                                    <h:outputLabel value="Channel Bill Cancellations"/>
                                </f:facet>     

                                <p:column headerText="Billed No." >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Billed No."/>
                                    </f:facet> 
                                    <h:outputLabel value="#{b.insId}" >
                                    </h:outputLabel>
                                </p:column>
                                <p:column headerText="Time"  >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Time"/>
                                    </f:facet> 
                                    <h:outputLabel value="#{b.createdAt}" >
                                        <f:convertDateTime pattern="hh:mm a"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Total" styleClass="averageNumericColumn">
                                    <h:outputLabel value="#{b.total}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Discount" styleClass="averageNumericColumn">
                                    <h:outputLabel value="#{b.discount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Cash" styleClass="averageNumericColumn"  >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Cash"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00" />
                                </p:column>
                                <p:column headerText="Credit" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Agent"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Agent'}" value="#{b.netTotal}"  >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Agent'}" value="0.00"/>

                                </p:column>

                                <p:column headerText="C Card" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="C Card"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
                                </p:column>

                                <p:column headerText="Checque" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Checque"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Cheque'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Cheque'}" value="0.00"/>
                                </p:column>

                                <p:column headerText="Slip" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Slip"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Slip'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Slip'}" value="0.00"/>
                                </p:column>

                                <p:columnGroup type="footer">  
                                    <p:row>                                 
                                        <p:column colspan="4"/>
                                        <p:column footerText="#{channelReportController.canceledBillList.cash}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.canceledBillList.cash}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.canceledBillList.agent}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.canceledBillList.agent}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.canceledBillList.card}" styleClass="averageNumericColumn">  
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.canceledBillList.card}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.canceledBillList.cheque}" styleClass="averageNumericColumn"> 
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.canceledBillList.cheque}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.canceledBillList.slip}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.canceledBillList.slip}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                    </p:row>  
                                </p:columnGroup>  

                            </p:dataTable>

                            <p:spacer height="30"/>

                            <p:dataTable id="tb3"  value="#{channelReportController.refundBillList.bills}" var="b">
                                <f:facet name="header">  
                                    <h:outputLabel value="Channel Bill Refunds"/>
                                </f:facet>     

                                <p:column headerText="Bill No." styleClass="averageNumericColumn">
                                    <f:facet name="header">  
                                        <h:outputLabel value="Bill No."/>
                                    </f:facet> 
                                    <h:outputLabel value="#{b.insId}" >
                                    </h:outputLabel>
                                </p:column>
                                <p:column headerText="Time"  >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Time"/>
                                    </f:facet> 
                                    <h:outputLabel value="#{b.createdAt}" >
                                        <f:convertDateTime pattern="hh:mm a"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Total" styleClass="averageNumericColumn">
                                    <h:outputLabel value="#{b.total}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Discount" styleClass="averageNumericColumn">
                                    <h:outputLabel value="#{b.discount}">
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                </p:column>

                                <p:column headerText="Cash" styleClass="averageNumericColumn"  >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Cash"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00" />
                                </p:column>
                                <p:column headerText="Credit" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Agent"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Agent'}" value="#{b.netTotal}"  >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Agent'}" value="0.00"/>

                                </p:column>

                                <p:column headerText="C Card" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="C Card"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
                                </p:column>

                                <p:column headerText="Checque" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Checque"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Cheque'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Cheque'}" value="0.00"/>
                                </p:column>

                                <p:column headerText="Slip" styleClass="averageNumericColumn" >
                                    <f:facet name="header">  
                                        <h:outputLabel value="Slip"/>
                                    </f:facet> 
                                    <h:outputLabel rendered="#{b.paymentMethod=='Slip'}" value="#{b.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                    <h:outputLabel rendered="#{b.paymentMethod!='Slip'}" value="0.00"/>
                                </p:column>

                                <p:columnGroup type="footer">  
                                    <p:row>                                 
                                        <p:column colspan="4"/>
                                        <p:column footerText="#{channelReportController.refundBillList.cash}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.refundBillList.cash}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.refundBillList.agent}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.refundBillList.agent}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.refundBillList.card}" styleClass="averageNumericColumn">  
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.refundBillList.card}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.refundBillList.cheque}" styleClass="averageNumericColumn"> 
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.refundBillList.cheque}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                        <p:column footerText="#{channelReportController.refundBillList.slip}" styleClass="averageNumericColumn">
                                            <f:facet name="footer">
                                                <h:outputLabel value="#{channelReportController.refundBillList.slip}">
                                                    <f:convertNumber pattern="#,##0.00"/>
                                                </h:outputLabel>
                                            </f:facet>
                                        </p:column>
                                    </p:row>  
                                </p:columnGroup>  

                            </p:dataTable>

                            <p:spacer height="30"/>

                            <p:dataTable id="sum3" value="#{channelReportController.channelSummary}"  var="i" >
                                <f:facet name="header">
                                    <h:outputLabel value="Channel Cashier Summary"/>
                                </f:facet>
                                <p:column>
                                    <h:outputLabel value="#{i.string}"/>
                                </p:column>
                                <p:column style="font-weight: bold;text-align:right;" >
                                    <h:outputLabel value="#{i.value}">
                                        <f:convertNumber pattern="#,##0.00" />
                                    </h:outputLabel>
                                </p:column>
                            </p:dataTable>  

                        </p:panel>

                        <p:spacer height="30"/>

                        <h:panelGrid columns="1">
                            <h:outputLabel value="Cashier : #{channelReportController.webUser.webUserPerson.name}"/>
                            <br/>
                            <h:outputLabel value="............................"/>
                        </h:panelGrid>
                        <f:facet name="footer" >
                            <h:outputLabel value="#{sessionController.loggedUser.webUserPerson.name}" style="float: right"/>
                        </f:facet>
                    </p:panel>

                </p:panel>
            </h:form>
        </h:panelGroup>
    </ui:define>

</ui:composition>
